package com.moi.summer;


import android.app.Activity;
import android.app.AlertDialog;
import android.content.Context;
import android.content.DialogInterface;
import android.util.AttributeSet;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.LinearLayout;
import android.widget.TextView;

public class CharacterTitleLayout extends LinearLayout implements View.OnClickListener {

    public CharacterTitleLayout(Context context, AttributeSet attrs) {
        super(context, attrs);
        LayoutInflater.from(context).inflate(R.layout.title, this);
        TextView back = (TextView) findViewById(R.id.tv_back);
        TextView edit = (TextView) findViewById(R.id.tv_edit);
        back.setOnClickListener(this);
        edit.setOnClickListener(this);
    }

    @Override
    public void onClick(View v) {
        switch (v.getId()) {
            case R.id.tv_back:
                ((Activity) getContext()).finish();
                break;
            case R.id.tv_edit:
                AlertDialog.Builder builder = new AlertDialog.Builder(getContext());
                builder.setTitle("噢肉！")//设置标题
                        .setMessage("脚本君艺考去了，没时间理我，所以什么都没有！")//设置提示消息
/*                        .setPositiveButton("确定",new DialogInterface.OnClickListener() {//设置确定的按键
                            @Override
                            public void onClick(DialogInterface dialog, int which) {
                                //do something
                            }
                        })*/
/*                        .setNegativeButton("取消",new DialogInterface.OnClickListener() {//设置取消按键
                            @Override
                            public void onClick(DialogInterface dialog, int which) {
                                //do something
                            }
                        })*/
                        .setNeutralButton("好吧",new DialogInterface.OnClickListener() {//中间按钮
                            @Override
                            public void onClick(DialogInterface dialog, int which) {
                                //do something
                            }
                        })
                        .setCancelable(false)//设置按返回键是否响应返回，这是是不响应
                        .show();//显示
                break;
        }

    }
}
